// mine.js
var ctx = wx.createCanvasContext('testCanvas');
ctx.drawImage('../../img/axAc.png', 0, 0, 320, 300);
ctx.drawImage('../../img/ax.png', 90, 90, 140, 140);
ctx.draw();
// 自定义标签
var app = getApp();
var iconPath = "../../images/icons/"
var tabs = [
    {
        "icon": iconPath + "mark.png",
        "iconActive": iconPath + "markHL.png",
        "title": "点击查看",
        "extraStyle": "",
    },
    
    
]
var userInfo = {
    avatar: "https://pic4.zhimg.com/e515adf3b_xl.jpg",

}


Page({

    // data
    data: {
    
        CARD:'',
        name:'',
        sex:'',
        IDcard:'',
        fileID:'',
        houseID:'',
        ioNumber:'',

    },
   

    onLoad:function(options){
            var that=this;
            console.log(app.globalData.sex)
            
                that.data.fileID=app.globalData.fileID,
                that.data.name=app.globalData.name,
                that.data.sex=app.globalData.sex,
                that.data.IDcard=app.globalData.IDcard,
                that.data.houseID=app.globalData.houseID,
                that.data.ioNumber=app.globalData.ioNumber
                console.log(that.data.ioNumber)
            
          },

        chakan(){

            var that=this;
            console.log(app.globalData.fileID)
            that.setData({
                fileID:app.globalData.fileID,
                name:app.globalData.name,
                sex:app.globalData.sex,
                IDcard:app.globalData.IDcard,
                houseID:app.globalData.houseID,
                ioNumber:app.globalData.ioNumber

            })
        },
        
clickMe:function(){

   
wx.cloud.database().collection('user').doc(app.globalData.ID).update({
    // data 传入需要局部更新的数据
    data: {
      // 表示将 done 字段置为 true
      name:app.globalData.name,
      sex:app.globalData.sex,
      fileID:app.globalData.fileID,
      IDcard:app.globalData.IDcard,
      houseID:app.globalData.houseID,
      ioNumber:app.globalData.ioNumber
    },
    success: function (res) {
      console.log("修改成功", res)
    },
})
wx.switchTab({
    url: '../mine/mine',
   })
},
        
    

        getExcel: function (contentArr) {
            var name=app.globalData.name;
        var sex=app.globalData.sex;
        var IDcard=app.globalData.IDcard;
        var houseID=app.globalData.houseID;
        var ioNumber=app.globalData.ioNumber;
        console.log(name)
            wx.cloud.callFunction({
              name: 'excelexport',
              data: {
                excelhead: ["姓名", "性别", "身份证号", "住户房号", "出入次数"],
                excelbody: [{'name':name,'sex':sex,'IDcard':IDcard,'houseID':houseID,'ioNumber':ioNumber}]
            
            
              },
              success: function (res) {
                console.log(res.result.fileID);
                console.log(456);
              },
              fail: function (res) {
                console.log(res);
                console.log(123);
              }
            })
          },
        
    // 点击tab项事件
    touchTab: function(event){
        var mima=app.globalData.mima;
        console.log(mima);
        var name=app.globalData.name;
        var sex=app.globalData.sex;
        var IDcard=app.globalData.IDcard;
        var fileID=app.globalData.fileID;
        var houseID=app.globalData.houseID;
        var ioNumber=app.globalData.ioNumber;
        console.log(name);
        var tabIndex = parseInt(event.currentTarget.id);
        var template = "tab" + (tabIndex + 1).toString();

        this.setData({
            currentTab: template,
            highLightIndex: tabIndex.toString(),
            mima:app.globalData.mima,
            name:app.globalData.name,
            IDcard:app.globalData.IDcard,
            fileID:app.globalData.fileID,
            sex:app.globalData.sex,
            houseID:app.globalData.houseID,
            ioNumber:app.globalData.ioNumber
        }
        );
    },

    // 点击新建日记按钮
    touchAdd: function (event) {
        this.setData({
            modalShowStyle: "opacity:1;pointer-events:auto;"
        })
    },

    // 新建日记
    touchAddNew: function(event) {
        this.hideModal();

        wx.navigateTo({
            url: "../new/new?title=" + this.data.diaryTitle,
        });
    },

    // 取消标题输入
    touchCancel: function(event) {
        this.hideModal();
        this.clearTitle();
    }, 

    // 标题输入事件
    titleInput: function(event) {
        this.setData({
            diaryTitle: event.detail.value,
        })
    }
})
